﻿using System;
using System.Data;
using System.Data.Common;

using SimpleService.Database;

namespace TestDB
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //SQL語法
            string strDbCon = String.Format("Data Source={0};User Id={1}; Password={2}; Database={3}; pooling=false", "82.103.129.94", "simpleservicee", "123123123qq", "simpleservicee");

            //這邊連線部分使用到SimpleService.Database
            DbOperation dbo = new DbOperation("SimpleService.Database.MysqlProvider");            
            DbConnection connection = dbo.GetConnection(strDbCon);
            DbCommand cmd = dbo.GetCommand("SELECT * FROM Users", connection);
            DbDataAdapter adp = dbo.GetDataAdapter(cmd);

            connection.Open();
            //從 DataAdapter 填入 DataSet
            DataSet ds = new DataSet();
            adp.Fill(ds);

            //顯示帳號密碼
            Response.Write(ds.Tables[0].Rows[0]["uid"].ToString());
            Response.Write("<br>");
            Response.Write(ds.Tables[0].Rows[0]["password"].ToString());

            connection.Close();
            
        }
    }
}